"""
 * index:
 *  0  1  2  3
 *  4  5  6  7
 *  8  9 10 11
 * 12 13 14 15

	tdl.add_feature(new pattern({ 0, 1, 2, 3, 4, 5 }));
	tdl.add_feature(new pattern({ 4, 5, 6, 7, 8, 9 }));
	tdl.add_feature(new pattern({ 0, 1, 2, 4, 5, 6 }));
	tdl.add_feature(new pattern({ 4, 5, 6, 8, 9, 10 }));

    board = np.array([0,..., 15])
"""

import numpy as np


def rotate_index(board_index):
    indexes = []

    indexes.append(np.copy(board_index))

    v_flip_index = np.copy(board_index)
    indexes.append(v_flip_index[::-1, :])

    t_flip_index = np.copy(board_index)
    indexes.append(t_flip_index.T)


    t_h_flip_index = np.copy(board_index)
    indexes.append((t_h_flip_index.T)[:, ::-1])

    return indexes


def get_indexes():
    board_index = np.arange(16).reshape((4, 4))
    indexes_list = rotate_index(board_index)
    indexes_list.extend(rotate_index(board_index[:, ::-1]))
    indexes_list = [index_array.flatten() for index_array in indexes_list]
    return indexes_list


def pattern_index(pattern):
    """
        pattern=[0, 1, 2, 3, 4, 5]
    """
    indexes = []
    for index in get_indexes():
        indexes.append(index[pattern])
    return indexes


if __name__ == '__main__':
    print(pattern_index([0, 1, 2, 3, 4, 5]))
    print(pattern_index([4, 5, 6, 7, 8, 9]))
    print(pattern_index([0, 1, 2, 4, 5, 6]))
    print(pattern_index([4, 5, 6, 8, 9, 10]))

